<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
	<title>发布商机</title>
	<link rel="stylesheet" type="text/css" href="../../css/aui-win.css" />
	<link rel="stylesheet" type="text/css" href="../../css/jquery.mobile-1.4.5.min.css">
<style>
.hr01, .hr02 {
	height: 28px;
}
body{
	font-weight: normal;
}
.headerico {
	padding: 0px 15px 5px 15px;
	color: #fff;
	font-size: 20px;
}
.content {
	width: 90%;
	margin: 10px auto;
}

.login {
	background-repeat: no-repeat;
	background-size: contain;
}
.loginbg {/*position: absolute;*/
	width: 100%;
}
.uploadImg {
	line-height: 35px;
	text-align: center;
	display: block;
	height: 35px;
	width: 30%;
	margin-left: 5%;
	font-size: 14px;
	color: rgba(255,255,255,1);
	border: 1px solid rgba(0,0,0,0.2);
	background-color: #00ABFD;
	border-radius: 5px;
	-webkit-border-radius: 5px;
	-moz-border-radius: 5px;
	margin-top: 5px;
	text-align: center;
}
#myheader li {
	list-style: none;
	display: inline-block;
}
#myheader li img {
	margin-left: 5px;
	width: 100px;
	height: 100px;
}
#description{
	height:150px !important;
}
</style>
</head>
<body>
	<div class="div_loding_img" style="display:none;">
		数据加载中
	</div>
	<header class="aui-bar aui-bar-nav aui-bar-yunzo" id="aui-header">
		<a class="aui-btn aui-bar-yunzo aui-pull-left" id="back" onclick="back_go()"> <span class="aui-iconfont aui-icon-left"></span></a>
		<div class="aui-title" id="title" style="text-shadow: 0 0 0;">
			发布商机
		</div>
		<a class="aui-iconfont aui-icon-menu aui-pull-right"></a>
	</header>
	<div class="margin_div"></div>
	<div class="content">
		<div class="mainDiv">
			<div style="margin-top: 5px;text-indent: 2em;">
				<input  type="radio" name="radio1" value="1" checked="checked" style="margin-top:-1px;"><span style="margin-left:37px;">对内发布</span>
				<input  type="radio" name="radio1" value="0" style="margin-top:-1px;"/><span style="margin-left:37px;">对所有人公开</span>
			</div>
			<div>
				<input id="name" type="text" placeholder="请输入联系人的姓名" required="required" maxlength="10" min="2" />
			</div>
			<div>
				<input id="tel" type="text" placeholder="请输入联系人的电话" required="required" maxlength="11" min="8" />
			</div>
			<div>
				<input id="txtcity" type="text"  placeholder="商机有效服务区(可填写多个地区)" required="required">
			</div>
			<div>
				<select id="industrys" name="industrys">
      				<option value="商业">商业</option>
     				 <option value="工业">工业</option>
     				 <option value="农业">农业</option>
     				 <option value="学业">学业</option>
    			</select>
			</div>
			<div>
				<select id="timeee" name="industrys">
      				<option value="三个月">有效期三个月</option>
     				 <option value="六个月">有效期六个月</option>
     				 <option value="十二个月">有效期十二个月</option>
     				 <option value="长期有效">长期有效</option>
    			</select>
			</div>
			<div>
				<input id="bustitle" type="text" placeholder="请输入商机标题" required="required"/>
			</div>
			<div>
				<textarea id="description"  placeholder="请输入商机描述" ></textarea>
			</div>
		</div>
		<div class="login">
			<div>
				<ul style="margin:5px 0 0 0;" id="myheader"></ul>
			</div>
			<input type="file" id="myheadimg" accept="image/*;capture=camera" name="myheadimg" style="display:none">
			<!--<input type="button" value="上传图片" class="uploadImg" onclick="myheadimg.click()" style="height:30px;margin-top:20px;">-->
		</div>
		<div>
			<input class="subBtn" type="button" value="提交" onclick="subClick()" />
		</div>
	</div>
<script src="../../script/jquery-1.10.2.min.js"></script>
<script src="../../script/jquery.mobile-1.4.5.min.js"></script>
<script src="../../script/common.js"></script>
<script type="text/javascript">
$("#name").val($myname)
$("#tel").val($mid)
var comlogo;
function subClick(){
	$(".div_loding_img").css("display","block")
	//uploadFile()
	uploadComplete();
}
/*$("#myheadimg").change(function(){
    fileSelected();
});
function fileSelected() {
    var file = document.getElementById('myheadimg').files[0];
    if (file) {
        var url=getObjectURL(file);
        $("#myheader").html("<img src='"+url+"' style='width:90px;height:90px;'>")
    }
}
function getObjectURL(file) {
    var url = null ; 
    if (window.createObjectURL!=undefined) { // basic
     url = window.createObjectURL(file) ;
    } else if (window.URL!=undefined) { // mozilla(firefox)
     url = window.URL.createObjectURL(file) ;
    } else if (window.webkitURL!=undefined) { // webkit or chrome
     url = window.webkitURL.createObjectURL(file) ;
    }
    return url ;
}
function uploadFile() {
        var fd = new FormData();
        fd.append("myheadimg", document.getElementById('myheadimg').files[0]);
        var xhr = new XMLHttpRequest();
       	xhr.upload.addEventListener("progress", uploadProgress, false);
        xhr.addEventListener("load", uploadComplete, false);
        xhr.addEventListener("error", uploadFailed, false);
        xhr.addEventListener("abort", uploadCanceled, false);
        xhr.open("POST", "../../../api/file/upload");
        xhr.send(fd);
}
function uploadProgress(evt) {
        if (evt.lengthComputable) {
          var percentComplete = Math.round(evt.loaded * 100 / evt.total);
          //document.getElementById('progressNumber').innerHTML = percentComplete.toString() + '%';
        }
        else {
        //  document.getElementById('progressNumber').innerHTML = 'unable to compute';
        }
}
function uploadFailed(evt) {
			$(".div_loding_img").css("display","none")
    	  alert("图片太胖，瘦身再传!");
      }

      function uploadCanceled(evt) {
    	  $(".div_loding_img").css("display","none")
        alert("已经取消,请重新选择图片!");
      }*/
function uploadComplete(/*evt*/) {
/*	var obj = JSON.parse(evt.target.responseText);
    if($("#myheadimg").val()!=""){  	
    	comlogo=obj.datum.myheadimg;
   	}
   	*/
   	var imageurl;
	var myheader;
	var uname;
	var utel;
	var isOpen;
	var ucity;
	var ubeginTime;
	var uendTime;
	var bustitle;
	var busdescription;
	var industry;
	$("[name='radio1'][checked]").each(function(){     
		 isOpen=$(this).val();        
	}) ;
	 uname=$("#name").val();
	 utel=$("#tel").val();
	 ucity= $("#txtcity").val();
	 ubeginTime=$("#timeee option:selected").val();
	 uendTime=$("#endTime").val();
	 industry=$("#industrys  option:selected").val();
	 bustitle= $("#bustitle").val();
	 busdescription= $("#description").val();
	 var re =/^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/;
	 if(re.test(utel)!=false&&ucity.length>=2&&bustitle.length>=4&&busdescription.length>=8){
		 
	 var bodyParam = {
		"groupid":$groupid,
		"mid":$mid,
		"did":initdata.get('busessinfo'),
		"biimages" : comlogo,
		"isopen" : isOpen,
		"bicontactname" : uname,
		"bicontacttell" : utel,
		"bicontacttrade" : industry,
		"bicontactaddress" : ucity,
		"bicontactvalidity" : ubeginTime,
		"bititle" : bustitle,
		"bicommnet" : busdescription
	};
    ajaxCoCRequest("../../../api/group/sendgroupbusinessinfo", "POST", bodyParam, function(msg){
        if(msg.code==100){
        	$(".div_loding_img").css("display","none")
            var c =confirm("发布已經成功,继续发布？")
            if(!c){
                window.history.go(-1);
            }
            else{
            	window.history.go(0)
            }
        }
        else{
        	$("body").append('<div class="wuwang"><img src="../../image/iconfont-wangluo.png"><p>网络拥堵，信息塞车</p></div>')  
        }
              
    });
}
	 else{
		 $(".div_loding_img").css("display","none")
		 alert("信息输入有误，内容不能为空！\n地区不能少于2个字\n标题不能少于4个字\n描述不能少于8个字")
	 }
}
</script>
</body>
</html>